package com.cmj.controller;

import com.cmj.domain.ResponseResult;
import com.cmj.domain.dto.ArticleDto;
import com.cmj.domain.entity.Article;
import com.cmj.domain.vo.ArticleListVo;
import com.cmj.service.ArticleService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 文章表(Article)表控制层
 *
 * @author makejava
 * @since 2022-03-12 16:43:19
 */
@RestController
@RequestMapping("/content/article")
@Api(tags = "文章",description = "文章相关接口")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping("/list")
    public ResponseResult articleList(Integer pageNum, Integer pageSize, ArticleDto articleDto){
        return articleService.articleList(pageNum,pageSize,articleDto);
    }

    @PostMapping
    public ResponseResult<ArticleListVo> addArticle(@RequestBody Article Article){
        return articleService.addArticle(Article);
    }

    //删除
    @DeleteMapping("{id}")
    public ResponseResult delArticle(@PathVariable("id") Long[] id){
        return articleService.delArticle(id);
    }

    //获取更新项信息
    @GetMapping("{id}")
    public ResponseResult<ArticleListVo> getArticle(@PathVariable("id") Long id){
        return articleService.getArticle(id);
    }

    //更新信息
    @PutMapping
    public ResponseResult updateArticle(@RequestBody Article Article){
        return articleService.updateArticle(Article);
    }
}

